<template>
<div>
  <h1>商品展示</h1>
  <table border="1" cellspacing="0" align="center">
    <tr>
      <td>商品名称</td>
      <td>商品价格</td>
      <td>商品评论</td>
      <td>总评价数</td>
      <td>操作</td>
    </tr>
    <tr v-for="i in shoplist">
      <td>{{i.name}}</td>
      <td>{{i.price}}</td>
      <td>{{i.comment}}</td>
      <td>{{i.count}}</td>
      <td>
        <button @click="comment(i.id)">评价</button>
      </td>
    </tr>
  </table>
</div>
</template>

<script>
export default {
  name: "X_shop",
  data(){
    return{
      shoplist:{},
    }
  },
  methods:{
    get_shoplist(){
      this.$axios.get('users/xshopm/')
      .then(res=>{
        console.log(res.data)
        this.shoplist=res.data.list
      })
    },
    comment(id){
      let userid=localStorage.getItem('userid')
      if(userid){
        this.$router.push({path:'/X_comment',query:{'id':id}})
      }else {
        this.$router.push('/X_Login')
      }
    },
  },
  mounted() {
    this.get_shoplist()
  }
}
</script>

<style scoped>

</style>
